Skip to content

perf(proxy-agent): avoid extra header allocations in auth guard#5164

Merged
mcollina merged 2 commits intonodejs:mainfrom
trivikr:proxy-agent-headers
May 6, 2026
Merged

perf(proxy-agent): avoid extra header allocations in auth guard#5164
mcollina merged 2 commits intonodejs:mainfrom
trivikr:proxy-agent-headers

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 2, 2026

This relates to...

ProxyAgent request header handling performance.

Rationale

ProxyAgent does extra work on in it's Proxy-Authorization guard every dispatch. Object headers currently allocate an Object.keys() array before scanning, and array headers are converted before the guard runs.

Changes

  • Check array headers for Proxy-Authorization while converting them in buildHeaders().
  • Replace Object.keys().find() with a for...in early-exit scan for object headers.

Features

N/A

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

Assisted-by: openai:gpt-5.5

Assisted-by: openai:gpt-5.5
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 2, 2026

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.26%. Comparing base (584e6ae) to head (dd0c2b1).

Files with missing lines Patch % Lines
lib/dispatcher/proxy-agent.js 80.95% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5164      +/-   ##
==========================================
- Coverage   93.26%   93.26%   -0.01%     
==========================================
  Files         110      110              
  Lines       36353    36370      +17     
==========================================
+ Hits        33906    33919      +13     
- Misses       2447     2451       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 4f8f814 into nodejs:main May 6, 2026
40 of 41 checks passed
@trivikr trivikr deleted the proxy-agent-headers branch May 6, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants